* Firm organization with multiple establishments
* Section III.C: Appendix Tables B.18

clear all 
set matsize 4000
set more off

capture log close
log using log/16_facts-p_dynMEorg_SE.log, replace

use data/MEorg_2000-2010_p_SE_transition.dta, clear

********************************************************************************
***	Table B.18: Transition dynamics of the managerial organization

tab2 count_mgmt_unt f_count_mgmt_unt if count_est == 1, m
tab2 count_mgmt_unt f_count_mgmt_unt if count_est == 1, m row nofreq

********************************************************************************
***	Table: Size at transition 

gen ln_empl_unt = ln(empl_unt)
gen ln_sales = ln(Sales)

cap drop cellsize
bys count_mgmt_unt f_count_mgmt_unt: egen cellsize = count(count_mgmt_unt) if count_est > 1
table count_mgmt_unt f_count_mgmt_unt if count_est > 1 & cellsize > 49, contents(count ln_empl_unt mean ln_empl_unt) format(%9.1f)
table count_mgmt_unt f_count_mgmt_unt if count_est > 1 & cellsize > 49, contents(count ln_sales mean ln_sales) format(%9.1f)

foreach outcome in ln_empl_unt ln_sales {
	ttest `outcome' if count_mgmt_unt == 0 & f_count_mgmt_unt == "0"	| count_mgmt_unt == 0 & f_count_mgmt_unt == "1", unequal by(f_count_mgmt_unt)
	ttest `outcome' if count_mgmt_unt == 0 & f_count_mgmt_unt == "0"	| count_mgmt_unt == 0 & f_count_mgmt_unt == "ME", unequal by(f_count_mgmt_unt)
	
	ttest `outcome' if count_mgmt_unt == 1 & f_count_mgmt_unt == "1"	| count_mgmt_unt == 1 & f_count_mgmt_unt == "0", unequal by(f_count_mgmt_unt)
	ttest `outcome' if count_mgmt_unt == 1 & f_count_mgmt_unt == "1"	| count_mgmt_unt == 1 & f_count_mgmt_unt == "2", unequal by(f_count_mgmt_unt)
	ttest `outcome' if count_mgmt_unt == 1 & f_count_mgmt_unt == "1"	| count_mgmt_unt == 1 & f_count_mgmt_unt == "ME", unequal by(f_count_mgmt_unt)
	
	ttest `outcome' if count_mgmt_unt == 2 & f_count_mgmt_unt == "2"	| count_mgmt_unt == 2 & f_count_mgmt_unt == "1", unequal by(f_count_mgmt_unt)
	ttest `outcome' if count_mgmt_unt == 2 & f_count_mgmt_unt == "2"	| count_mgmt_unt == 2 & f_count_mgmt_unt == "3", unequal by(f_count_mgmt_unt)
	ttest `outcome' if count_mgmt_unt == 2 & f_count_mgmt_unt == "2"	| count_mgmt_unt == 2 & f_count_mgmt_unt == "ME", unequal by(f_count_mgmt_unt)
	
	ttest `outcome' if count_mgmt_unt == 3 & f_count_mgmt_unt == "3"	| count_mgmt_unt == 3 & f_count_mgmt_unt == "1", unequal by(f_count_mgmt_unt)
	ttest `outcome' if count_mgmt_unt == 3 & f_count_mgmt_unt == "3"	| count_mgmt_unt == 3 & f_count_mgmt_unt == "2", unequal by(f_count_mgmt_unt)
	ttest `outcome' if count_mgmt_unt == 3 & f_count_mgmt_unt == "3"	| count_mgmt_unt == 3 & f_count_mgmt_unt == "ME", unequal by(f_count_mgmt_unt)
}

erase "data/MEorg_2000-2010_p_SE_transition.dta"

log close
